package com.suxin.event.annotations;

import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.transaction.event.TransactionalEventListener;

import java.lang.reflect.Method;

/**
 * @author Tang
 * @classname TransactionalEventListenerFactory
 * @description [  ]
 * @date 2023/2/28 16:26
 */
public class TransactionalEventListenerFactory implements EventListenerFactory{

    @Override
    public boolean supportsMethod(Method method) {
        return AnnotationUtils.findAnnotation(method, TransactionalEventListener.class) != null;
    }

    @Override
    public ApplicationListener<?> createApplicationListener(Method method, String beanName, Class<?> clz) {
        return new TransactionalApplicationListenerMethodAdapter(method,beanName,clz);
    }
}
